package com.webbei.myshare.action;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.webbei.share.action.ShareChildInfo;
import com.webbei.share.service.ShareSer;
import com.webbei.pojo.Customcomment;
import com.webbei.pojo.Customs;
public class GetShareChild extends ActionSupport{
	private ShareSer ser;
	private String userName;
	List<String> username1 = new ArrayList<String>();
	List<String> username2=new ArrayList<String>();
	List<String> username1_comment=new ArrayList<String>();
	List<String> username2_comment=new ArrayList<String>();
	List<Integer> comment_count=new ArrayList<Integer>();
	List<Integer> firstcomment_id=new ArrayList<Integer>();
	List<Integer> secondcomment_id=new ArrayList<Integer>();
	public String execute(){
		List<Customs> list=ser.getCustomByUserName(userName);
		for(int i=0;i<list.size();i++)
		{
			List<Customcomment> temp=ser.getFirstTwoComment(list.get(i).getCustomId());
			if(temp.size()>0)
			{
				username1.add(temp.get(0).getUserName());
				username1_comment.add(temp.get(0).getCommentContent());
				firstcomment_id.add(temp.get(0).getCommentId());
				if(temp.size()>1)
				{
					username2.add(temp.get(1).getUserName());
					username2_comment.add(temp.get(1).getCommentContent());
					secondcomment_id.add(temp.get(1).getCommentId());
				}
				else{
					username2.add("");
					username2_comment.add("");
					secondcomment_id.add(0);
				}
				comment_count.add(temp.size());
			}
			else{
				this.setStringZero(username1);
				this.setStringZero(username2);
				this.setStringZero(username1_comment);
				this.setStringZero(username2_comment);
				this.serIntZero(comment_count);
				this.serIntZero(firstcomment_id);
				this.serIntZero(secondcomment_id);
			}
		}
		return "success";
	}
	
	public List<String> getUsername1() {
		return username1;
	}

	public void setUsername1(List<String> username1) {
		this.username1 = username1;
	}

	public List<String> getUsername2() {
		return username2;
	}

	public void setUsername2(List<String> username2) {
		this.username2 = username2;
	}

	public List<String> getUsername1_comment() {
		return username1_comment;
	}

	public void setUsername1_comment(List<String> username1_comment) {
		this.username1_comment = username1_comment;
	}

	public List<String> getUsername2_comment() {
		return username2_comment;
	}

	public void setUsername2_comment(List<String> username2_comment) {
		this.username2_comment = username2_comment;
	}

	public List<Integer> getComment_count() {
		return comment_count;
	}

	public void setComment_count(List<Integer> comment_count) {
		this.comment_count = comment_count;
	}

	public List<Integer> getFirstcomment_id() {
		return firstcomment_id;
	}

	public void setFirstcomment_id(List<Integer> firstcomment_id) {
		this.firstcomment_id = firstcomment_id;
	}

	public List<Integer> getSecondcomment_id() {
		return secondcomment_id;
	}

	public void setSecondcomment_id(List<Integer> secondcomment_id) {
		this.secondcomment_id = secondcomment_id;
	}

	private void setStringZero(List<String> temp){
		temp.add("");
	}
	private void serIntZero(List<Integer> temp){
		temp.add(0);
	}
	public void setSer(ShareSer ser) {
		this.ser = ser;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
}
